package com.yuzhou.dao;

import com.yuzhou.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;


public interface UserDao {
//    根据微信的openId查询用户
    @Select("select * from user where openId = #{openId}")
    User findByOpenId(String openId);

//    新增用户
    @Insert("insert into user values(null,#{nickName},#{avatarUrl},#{openId},#{topScore})")
    void add(User user);

//    更新最高分数
    @Update("update user set topScore=#{topScore} where openId=#{openId} and #{topScore}>topScore")
    void updateTopScore(User user);
}
